(ns lr.image
  (:import (java.awt.image BufferedImage)
	   (java.awt Color Graphics2D)
	   (java.io File FileOutputStream)
	   (javax.imageio ImageIO)))

(def width 640)
(def height 480)
(def num-pixels (* width height))
(def num-samples (* 3 num-pixels))

(def fname "out.png")

;;The RGB image.
(def image (new BufferedImage width height BufferedImage/TYPE_INT_RGB))

(def graphics-context (. image createGraphics))

;;WritableRaster
(def raster (. image getRaster))

(def image-data (int-array num-samples))

(defn write-out []
  (. raster setPixels 0 0 width height image-data)
  (. ImageIO write image "png" (new FileOutputStream (new File fname)))
  (println "image written"))
